Skip to content

Add IsSquareMat and IsAntisymmetricMat#6268

Open
limakzi wants to merge 1 commit intogap-system:masterfrom
limakzi:6264-add-issquare
Open

Add IsSquareMat and IsAntisymmetricMat#6268
limakzi wants to merge 1 commit intogap-system:masterfrom
limakzi:6264-add-issquare

Conversation

@limakzi
Copy link
Member

@limakzi limakzi commented Mar 12, 2026

Add IsSquareMatrix/IsSquareMat to check whether a matrix is square.
Add IsAntisymmetricMatrix/IsAntisymmetricMat to check whether mat[i,j] = -mat[j,i] for all entries.

Both symmetric and antisymmetric matrices imply IsSquareMatrix via InstallTrueMethod. IsSymmetricMatrix is simplified to use IsSquareMatrix instead of an inline dimension check.

Fixes #6264.

Copilot AI review requested due to automatic review settings March 12, 2026 22:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds new matrix properties to the matrix subsystem, improving reuse and consistency across related predicates.

Changes:

  • Introduces IsSquareMatrix / IsSquareMat and adds test coverage for square vs. non-square matrices.
  • Introduces IsAntisymmetricMatrix / IsAntisymmetricMat (with documentation and tests).
  • Refactors IsSymmetricMatrix to use IsSquareMatrix, and installs implications that symmetric/antisymmetric matrices are square.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tst/testinstall/matrix.tst Adds tests for IsSquareMat and IsAntisymmetricMat.
lib/matrix.gi Implements IsSquareMatrix and IsAntisymmetricMatrix; simplifies IsSymmetricMatrix square-check.
lib/matrix.gd Declares new properties/synonyms, adds GAPDoc entries, and installs implications to IsSquareMatrix.
doc/ref/matrix.xml Includes the new GAPDoc sections in the reference manual.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@fingolfin fingolfin changed the title Add IsSquareMat and IsAntisymmetricMat Add IsSquareMat and IsAntisymmetricMat Mar 18, 2026
return NrRows( mat ) = NrCols( mat );
end );

InstallTrueMethod( IsSquareMatrix, IsMatrixOrMatrixObj and IsEmptyMatrix );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... is a $0\times 2$ matrix square?

fi;
zero := ZeroOfBaseDomain( mat );
for i in [ 1 .. NrRows( mat ) ] do
if mat[i,i] <> zero then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the wrong condition in characteristic 0, isn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In characteristic 2, you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argh, yes (actually: in even positive characteristic, not just 2.

But the solution is the same: just remove this special case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add IsSquareMat / IsAntisymmetricMat

4 participants